<template name='person_admin'>
	<view>
		<view style="width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
			<view style="width: 96%;position: absolute; top:0; background-color: #FFFFFF;box-shadow: 1px 1px 5px #C0C0C0;padding-top: 20upx;">
				<view style="width: 90%;padding: 30upx;display: flex;flex-direction: row;justify-content: center;align-items: center;border-bottom: 1px solid #EBEEF5;">
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{pageCount.task_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								项目总数
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{pageCount.not_ready_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								待初审
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{pageCount.other_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								正在进行
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{pageCount.fail_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								已驳回/众筹失败
							</view>
						</view>
					</view>
				
				
				<!-- 数据列表 -->
				<view style="color: #606270;display: flex;width: 100%;justify-content: center;font-size: 15px;flex-direction: column;align-items: center;">
					<view style="border-bottom: 1px solid #EBEEF5;display: flex;flex-direction: row;width: 95%;background-color: #F5F7FA;padding: 10upx;">
						<!-- <checkbox :checked="choose_all_" @click="choose_all" style="transform:scale(0.7);width: 5%;"/> -->
						<view style="width: 20%;">
							项目ID
						</view>
						<view style="width: 20%;">
							创建者ID
						</view>
						<view style="width: 5%;">
							状态
						</view>
						<view style="width: 30%;">
							项目相关信息
						</view>
						<view style="width: 30%;">
							里程碑相关信息
						</view>
						
						<view style="width: 15%;">
							操作
						</view>
					</view>
					<view v-for="(item,index) in pageList" :key=index class="list_detail" style="display: flex;justify-content: center;width: 95%;;align-items: center;">
						<!-- <checkbox :value="item.id.toString()" :checked='checkbox' style="transform:scale(0.7);width: 5%;"/> -->
						<view style="width: 20%;">
							{{item.task_id}} 
						</view>
						<view style="width: 20%;">
							{{item.user_id}} 
						</view>
						<view style="width: 5%;">
							{{item.status}} 
						</view>
						<!-- <view style="width: 23%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin-right: 1%;"> -->
						<view style="width: 30%;word-wrap: break-word; margin-right: 1%; ">
							项目名：{{item.name}}</br>项目描述：{{item.task_desc}}</br>总金额：{{item.price}}</br>奖励类型：{{item.reward_type}}</br>奖励说明：{{item.reward_desc}}
						</view>
						<view style="width: 30%;">
							<view v-for="(i,index1) in item.inputItems" style="">
								里程碑{{index1+1}}:目标{{i.text}}。金额{{i.price}}
							</view>
						</view>
						<!-- <view style="width: 11%;">
							{{item.food_price}}
						</view> -->
						<view style="width: 15%;display: flex;flex-direction: row;">
							<view v-if="item.status=='即将众筹'" @click="alter(item)" class="alter" style="">
								同意
							</view>
							<view v-else class="alter" style="color: brown;">
								已同意
							</view>
							<view v-if="item.status=='众筹失败'"  class="delete" style="color: brown;">
								已驳回
							</view>
							<view @click="fail(item)" class="delete" style="">
								驳回
							</view>
						</view>
					</view>
					</checkbox-group>
					
				</view>
				<!-- 数据列表end -->
			</view>
		</view>
		<!-- 编辑遮罩层 -->
		<uni-popup ref="popup" type="center">
		    <view style="width: 500upx;display: flex;background-color: #FFFFFF;flex-direction: column;box-shadow: 1px 1px 1px #808080;border-radius: 2upx;">
		        <view style="border-bottom: 1px solid #DCDFE6;font-size: 18px;display: flex;flex-direction: row;padding: 20upx;width: 460upx;align-items: center;">
					<view>
						项目初审
					</view>
					<image class='alter_sure' @tap="close" src="../../static/close.png" style="margin-left: auto;height: 15upx;width: 15upx;padding: 5upx;"></image>
				</view>
		        <view style="border-bottom: 1px solid #DCDFE6;color: #606266;font-size: 15px;width: 440upx;padding: 30upx;display: flex;flex-direction: column;justify-content: center;align-items: center;">
					
					<view style="width: 360upx;padding: 15upx;display: flex;flex-direction: row;align-items: center;">
						<view style="color: red;">
							*已完成项目审核并同意该项目启动第一个里程碑*
						</view>
						
					</view>
					
				</view>
				<view style="width: 100%;display: flex;align-items: center;font-size: 12px;color: #FFFFFF;">
					<view style="width: 60%;display: flex;flex-direction: row;align-items: center;padding: 15upx;">
						<view @click="alter_cancel" style="margin-left: auto;padding: 8upx 15upx 8upx 15upx;color: #606266;border: 1px solid #DCDFE6;">
							取 消
						</view>
						<view @click="alter_sure" style="margin-left: 18upx;padding: 8upx 15upx 8upx 15upx;background-color:#1890FF">
							确 定
						</view>
					</view>
				</view>
		    </view>     
		</uni-popup>
	</view>
	
</template>

<script>
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	import global from "@/common/global.js"
	export default{
		name:'admin_person',
		components: {
			uniPopup
		},
		data(){
			return{
				c_lcb: '',
				c_id: '',
				// 添加的菜品内容
				add_name:'',
				add_raw:'',
				add_type:'',
				add_price:'',
				// 添加图片
				add_pic:'http://cd7.yesapi.net/0B4163C86181759DD5DE6C761AF719A5_20200719144322_4f6d7c84144913a990f9532d76df3ace.png',
				add_pic_url:'',
				
				
				
			}
		},
		 // 此处定义传入的数据
		props: {
			pageCount: {
			    value: {}
			},
			pageList: {
			    type: Array,
			    value: null
			},
		},
		
		methods:{
			alter_cancel(){
				this.$refs.popup.close()
			},
			alter_sure(){
					var that = this
					console.log(that.c_id)
					uni.showModal({
						title:'请确认',
						content: '项目里程碑: '+ this.c_lcb ,
						confirmText: '确认通过',
						cancelText: '取消操作',
						success: function (res) {
								if (res.confirm) {
									uni.request({
										url:global.baseUrl+'api/task/task_admin_status',
										method: "POST",
										data:{
											task_id: that.c_id,
											status: '正在进行'
										},					
										success: function (res) {
											console.log(res)
												if(res.data.code == 10000){
													uni.showToast({
														icon: 'none',
														title:'已同意该项目',
														duration: 2000
													})
													
													  setTimeout(() => {
													    uni.navigateTo({
													        url: '/pages/admin/admin'
													      });
													  }, 1500);
												}else{
													uni.showToast({
														icon: 'none',
														title:'失败',
														duration: 2000
													})
												}
											}
										})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
								that.close()
							}
					})
					
				
			},
			close(){
				this.$refs.popup.close()
			},
			alter:function(e){
				this.c_lcb  = ''
				this.$refs.popup.open()
				console.log(e)
				this.c_id = e.task_id
				this.c_lcb = '项目：'+e.name+ '。\n里程碑1：目标=>'+e.inputItems[0].text + '。金额=>'+ e.inputItems[0].price +'\n'
				
				// this.c_lcb = e.inputItems
			},
			fail(item){
				uni.showModal({
					title:'请确认',
					content: '驳回该项目： '+ item.name ,
					confirmText: '确认驳回',
					cancelText: '取消操作',
					success: function (res) {
							if (res.confirm) {
								uni.request({
									url:global.baseUrl+'api/task/task_admin_status',
									method: "POST",
									data:{
										task_id: item.task_id,
										status: '众筹失败'
									},					
									success: function (res) {
										console.log(res)
											if(res.data.code == 10000){
												uni.showToast({
													icon: 'none',
													title:'已驳回该项目',
													duration: 2000
												})
												
												  setTimeout(() => {
												    uni.navigateTo({
												        url: '/pages/admin/admin'
												      });
												  }, 1500);
											}else{
												uni.showToast({
													icon: 'none',
													title:'驳回失败',
													duration: 2000
												})
											}
										}
									})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
							
						}
				})
			},
			change_page:function(e){
				console.log(e)
				var that = this
				if(e != '...'){
					that.NowPage = e
					that.checkbox = false
					that.checkbox_status =[]
					if(e >= 4&&e <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = e-2;i<e+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(e<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:e, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
				
			},
			page_delete:function(){
				var that = this
				if(that.NowPage<=1){
					alert('已经是首页了！')
				}else{
					that.NowPage = that.NowPage-1
					if(that.NowPage >= 4&&that.NowPage <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = that.NowPage-2;i<that.NowPage+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(that.NowPage<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:that.NowPage, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
			},
			page_add:function(){
				var that = this
				if(that.NowPage>=that.PageNum){
					console.log('不合格')
					alert('已经是尾页了！')
				}else{
					that.NowPage = that.NowPage+1
					if(that.NowPage >= 4&&that.NowPage <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = that.NowPage-2;i<that.NowPage+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(that.NowPage<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:that.NowPage, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
			}
				
		}
	}
</script>

<style>
	.input_image{
		height: 100upx;
		width: 100upx;
		margin-left: 20upx;
		border: 1px solid #DCDFE6;
	}
	.input_confirm_image{
		height: 100upx;
		width: 100upx;
		margin-left: 20upx;
		border: 1px solid #1890FF;
	}
	.input_image:hover{
		border: 1px solid #C8C7CC;
	}
	.alter_sure{
		margin-left: auto;height: 15upx;width: 15upx;padding: 5upx;
		border: 1px solid #FFFFFF;
	}
	.alter_sure:hover{
		border: 1px solid #C8C7CC;
	}
	.add_color{
		background-color: #1890FF;
		
	}
	.add_color:hover{
		background-color: #46A6FF;
	}
	.admin_pic{
		width: 180upx;
		height: 50upx;
		padding: 20upx;
	}
	.admin_pic:hover{
		background-color: #2C405A;
	}
	.arrow{
		height: 20upx;
		width: 20upx;
		
		margin-left: auto;
	}
	.arrow1{
		height: 18upx;
		width: 18upx;
		
	}
	.detail{
		padding: 20upx 20upx 20upx 40upx;
		width: 160upx;
		display: flex;
		flex-direction: row;
		color: #FFFFFF;
		font-size: 15px;
		align-items: center;
		
	}
	.detail:hover{
		background-color: #1890FF;
	}
	.list_detail{
		border-bottom: 1px solid #EBEEF5;display: flex;flex-direction: row;width: 100%;padding: 10upx;
	}
	.list_detail:hover{
		background-color: #F5F7FA;
	}
	.alter{
		color: #1890FF;
	}
	.alter:hover{
		text-decoration: underline;
		color: #DD524D;
	}
	.delete{
		color: #1890FF;margin-left: 10upx;
	}
	.delete:hover{
		text-decoration: underline;
		color: #DD524D;
	}
	.left{
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}
	.page{
		color: #FFFFFF;
		background-color: #1890FF;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
	}
	.nopage{
		color: #FFFFFF;
		background-color: #F4F4F5;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
		color: #606270;
	}
	.right{
		margin-left: 10upx;
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}
	.input_account{
		padding: 5upx 15upx 5upx 15upx;border: 1px solid #DCDFE6;width: 250upx;font-size: 13px;margin-left: 20upx;
	}
	.input_account:hover{
		border: 1px solid #C8C7CC;
	}
	.input_account1{
		padding: 5upx 15upx 5upx 15upx;border: 1px solid #DCDFE6;width: 227upx;font-size: 13px;margin-left: 20upx;
	}
	.input_confirm{
		border: 1px solid #1890FF;
		padding: 5upx 15upx 5upx 15upx;width: 250upx;font-size: 13px;margin-left: 20upx;
	}
	
	.back_color{
		background-color: #FF4D4F;
	}
	.back_color:hover{
		background-color: #FF7172;
	}
	.show_image{
		width: 50%;height: 100upx;
	}
	.show_image:hover{
		transform: scale(1.3);
	}
</style>
